<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<div class="dialog-warp-ajax">
    <form action="" id="punishAdd">
        <table class="dggui-table-info">
            <tbody>
            <tr>
                <th><span class="required">业态：</span></th>
                <td>
                    <div>${ytName}</div>
                </td>
            </tr>
            <tr>
                <th><span class="required">方案名称：</span></th>
                <td>
                    <div class="unit-warp">
                        <input type="text"  class="dggui-input" id="punishName" name="punishName"  value=""/>
                    </div>
                </td>
            </tr>
            <tr>
                <th><span>方案介绍：</span></th>
                <td>
                    <textarea placeholder="方案介绍非必填，请控制在50字以内" class="dggui-textarea" id="introduce" name="introduce" maxlength="50" style="min-width: 280px;width: 280px;"></textarea>
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
<script>
    function punishCreate(index){
        var introduce = $('#introduce').val();
        var punishName = $('#punishName').val();
        if(punishName.trim()=='' || punishName.trim() == null){
            dggui.dialog.tip('方案名称不能为空！',$('#punishName'));
            return;
        }
        if(punishName.trim().length>10){
            dggui.dialog.tip('方案名称不能超过10个字！',$('#punishName'));
            return;
        }
        if(introduce.trim() != '' && introduce != null && introduce.trim().length>50){
            dggui.dialog.tip('方案介绍不能超过50个字！',$('#introduce'));
            return;
        }

        var params = $('#punishAdd').serializeArray();
        dggui.dialog.loading();
        $.ajax({
            type: 'POST',
            async: true,
            data: params,
            url: sysInfo.basePath + '/rzsc/punish/add_punish.do',
            dataType: 'JSON',
            success: function (data) {
                dggui.dialog.loading('close');
                if (data.code == 0) {
                    layer.close(index);
                    dggui.dialog.succeed('操作成功！')
                    //刷新列表
                    reloadTable($('#punishScheme'),"reloadFalse");
                } else {
                    dggui.dialog.errors(data.msg);
                }
            },
            error: function () {
                dggui.dialog.loading('close');
                dggui.dialog.errors('保存失败，请联系管理员！！');
            }
        })
    }
</script>
